home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
rcdsplay.zip
/
GRAFED.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-05-25
|
52KB
|
1,233 lines
{*************************************************************************
TITLE : GRAFED
VERSION : 2.1
AUTHOR : Roger Carlson (after GRAFED5, version 3.2 of M.Riebe and
R.Carlson written for the IBM CS9000 computer) 5/29/90
FUNCTION: This unit contains the GRAF routine for interactive display of
xy data.
INPUTS : DATA - The xy data. The first index identifies x(1) or y(2)
and the second index specifies the data point.
FILENAME - Name of the data file.
MINX - Minimum x value.
MAXX - Maximum x value.
LOY - Smallest y value.
HIY - Largest y value.
NUMPTS - Number of data points.
NOTES : 1. In Turbo Pascal the maximum size of any variable is 64KB.
To use the largest possible data array sizes, I've used
a single precision data array, which uses 23 bit (7-8digit)
precision.
CHANGES : 6/2/90 (1.1,RJC) - Added window selection.
6/3/90 (1.2,RJC) - Modified to change passed parameters to
include x max and min rather than first and last index.
6/4/90 (1.3,RJC) - Added parameter window at bottom of screen.
6/12/90 (1.4,RJC) -Added crosshair, ruler and several bells and
whistles.
7/6/90 (1.5,RJC) - Started some bells and whistles. Moved
CLRBOX to AXISLBL.
3/23/91 (1.6,RJC) -Increased the maximum data array size to
7000 and changed data array type to single precision. Also
changed screen driver path to d:\tp to be consistent with
lab computer setup.
3/28/91 (1.7,RJC) -Added peak integration routine and completed
the moving average option.
5/2/91 (1.8,RJC) - Corrected text file dump procedure to include
data filtering.
5/3/91 (1.9,RJC) - Added linear transformation of axes,
wavelength/wavenumber conversion of x axis, and change of
axis labels.
5/9/91 (2.0,RJC) - Added postscript print screen procedure,
user defined window bounds, pan left, pan right, expand
horizontally, dos shell command, and crosshair trace mode.
5/23/91 (2.1,RJC) - Corrected an array range error when the
newmode flag was set (eg for a linear transform of x). Added
min/max procedure and nonlinear transforms.
*************************************************************************}
UNIT GRAFED;
{$I-} {Disable IO checking.}
INTERFACE
USES IOFUNCS; {version 1.7}
CONST MAXPTS=7000; {Maximum # of data points.}
TYPE DARRAY=ARRAY[1..2,1..MAXPTS] OF SINGLE;
PROCEDURE GRAF(VAR DATA:DARRAY; FILENAME:STR20; MINX,MAXX,LOY,HIY:REAL;
NUMPTS:INTEGER);
IMPLEMENTATION
USES CRT,GRAPH,DOS,
MATH, {VERSION 1.3}
AXISLBL; {VERSION 2.6}
PROCEDURE GRAF;
CONST
DRIVERS='d:\tp'; {location of device drivers}
SCRLEFT=100; {plot starts SCRLEFT units from left edge}
SCRBOTTOM=58; {bottom of plot SCRBOTTOM units from screen bottom}
SCRTOP=28; {top of plot SCRTOP unit from screen top}
LINE1=3; {first line for window at top of screen}
LINE2=13; {second line for window at top of screen}
VAR
ASCII : INTEGER; {ordinal value of a key pressed}
BWBSC : integer; {bottom window boundary in screen coordinates}
BWBUC : REAL; {bottom window bound in user coordinates}
CHFLAG : BOOLEAN; {turns crosshair display on}
CHSENS : INTEGER; {crosshair movement sensitivity}
CHXUC,CHYUC : REAL; {crosshair user coordinates}
CHXSC,CHYSC : INTEGER; {crosshair screen coordinates}
DONEFLAG : BOOLEAN; {flag to bet out of program}
ELIPSFLAG : BOOLEAN; {flags circling of each point}
ERRCODE : integer; {error code}
FILTYPE,
FILDEGREE,
FILDERIV,
FILWIDTH : INTEGER; {filter parameters}
FIRST : INTEGER; {index of current first displayed point}
FRAME : BOOLEAN; {flags need to redraw frame}
GRAPHDRIVER : integer; {graphics device ID number}
GRAPHMODE : integer; {mode for the graphics device}
HIXUC : REAL; {highest x user coordinate}
kbdbox : viewporttype; {graphics window at bottom of screen}
LAST : INTEGER; {index of last point currently displayed}
LINEFLAG : BOOLEAN; {flags connecting of points with lines}
LINFLAG : BOOLEAN; {flag to indicate choice of movable line}
LINLEN : INTEGER; {length of line in number of pixels}
LINXSC,LINYSC: INTEGER; {line screen coordinates}
LINXUC,LINYUC: REAL; {line user coordinates}
LOXUC : REAL; {lowest x value in user coordinates}
LWBIC : INTEGER; {lefg window boundary in index coordinates}
LWBSC : integer; {left window boundary in screen coordinates}
LWBUC : REAL; {left window boundary in user coordinate}
NEWMODE : BOOLEAN; {flags choice of a new display mode}
OLDBWBUC : REAL; {temporary bottom window bound in user coords}
OLDLWBUC : REAL; {temporary left window bound in user coords}
REDRAW : BOOLEAN; {flags need to redraw the screen plot}
RWBIC : INTEGER; {rigth window boundary in index coordinates}
RWBSC : integer; {right window boundary in screen coordinates}
RWBUC : REAL; {right window boundary in user coordinate}
SCANCODE : INTEGER; {extended code for a key pressed}
STEPSIZE : INTEGER; {size of increments between points}
THETA : REAL; {angle of live vs. horizontal (radians)}
TRACE : BOOLEAN; {flags crosshair trace mode}
TWBSC : integer; {top window boundary in screen coordinates}
TWBUC : REAL; {top window boundary in user coordinates}
titlebox : viewporttype; {graphics window at top of screen}
WINDSENS : INTEGER; {window movement sensitivity}
XLABEL : STR40; {label for x axis}
YLABEL : STR40; {label for y axis}
{************************ Coordinate Transformations ********************}
FUNCTION XCOORDSC(DATAPT:REAL):INTEGER; BEGIN
{Returns x value in screen coordinates corresponding to the user
value DATAPT by comparing it to the left and right window boundaries
in user coordinates.}
XCOORDSC:=ROUND((DATAPT-LWBUC)*((RWBSC-LWBSC)/(RWBUC-LWBUC))+LWBSC);
END; {XCOORDSC}
FUNCTION XDATAVAL(INDEX:INTEGER):REAL;
{Returns x coordinate value in user specified units for a given index
with user specified slope and intercept incorporated.}
BEGIN
IF (INDEX>=1) AND (INDEX<=NUMPTS) THEN XDATAVAL:=DATA[1,INDEX]
ELSE XDATAVAL:=(INDEX-1)*(DATA[1,NUMPTS]-DATA[1,1])/(NUMPTS-1)+DATA[1,1]
END; {XDATAVAL}
FUNCTION YCOORDSC(DATAPT:REAL):INTEGER; BEGIN
{Returns y value in screen coordinates corresponding to the supplied
user coordinate of the current point by comparing it to the top and
bottom displayed user coordinates.}
YCOORDSC:=ROUND((DATAPT-BWBUC)*((TWBSC-BWBSC)/(TWBUC-BWBUC))+BWBSC);
END; {YCOORDSC}
FUNCTION XCOORDUC(DATAPT:REAL):REAL; BEGIN
{Returns the x value in user coordinates corresponding to the supplied
screen coordinate of a point.}
XCOORDUC:=(DATAPT-LWBSC)*(RWBUC-LWBUC)/(RWBSC-LWBSC)+LWBUC;
END;
FUNCTION YCOORDUC(DATAPT:REAL):REAL; BEGIN
{Returns the y value in user coordinates corresponding to the suppied
screen coordinate of a point.}
YCOORDUC:=(DATAPT-BWBSC)*(TWBUC-BWBUC)/(TWBSC-BWBSC)+BWBUC;
END;
FUNCTION YDATAVAL(INDEX:INTEGER):REAL;
{Returns y coordinate value in specified units for a given index to
the data array.}
VAR TEMPINDEX:INTEGER;
BEGIN
IF INDEX>LAST THEN TEMPINDEX:=LAST
ELSE IF INDEX<FIRST THEN TEMPINDEX:=FIRST
ELSE TEMPINDEX:=INDEX;
IF TEMPINDEX<=1 THEN TEMPINDEX:=1;
IF TEMPINDEX>=NUMPTS THEN TEMPINDEX:=NUMPTS;
YDATAVAL:=DATA[2,TEMPINDEX];
END; {YDATAVAL}
{********************* FUNCTION FILTER ***************************